package com.asset.salesforce.dao;

import java.util.ArrayList;
import java.util.List;


import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.asset.salesforce.domain.JobTitle;

@Repository
public class JobTitleDao {

@Autowired
SessionFactory sessionFactory;

@SuppressWarnings("unchecked")
public List<JobTitle> getAllJobtitle() {
	
	return sessionFactory.getCurrentSession().createQuery("from JobTitle").list();
	
	
}

@SuppressWarnings("unchecked")
public JobTitle getJobtitleById(Integer id) {
	
	org.hibernate.Session session = sessionFactory.getCurrentSession();
	Query query= session.createQuery("from JobTitle where id = :id");
	query.setParameter("id", id);
	List<JobTitle>jobTitles =new ArrayList<JobTitle>();
	jobTitles=query.list();
	return jobTitles.get(0);
	
	
}

}

